import request from '@/utils/request'

// 获取商品列表
export function getProductList(params) {
  return request({
    url: '/goods/index',
    method: 'post',
    data: {
      param: params
    }
  })
}

// 获取商品详情
export function getProductDetail(goodsId) {
  return request({
    url: '/goods/detail',
    method: 'post',
    data: {
      param: {
        goodsId
      }
    }
  })
}

// 创建商品
export function createProduct(data) {
  return request({
    url: '/goods/create',
    method: 'post',
    data: {
      param: data
    }
  })
}

// 更新商品
export function updateProduct(goodsId, data,type=1) {
  return request({
    url: '/goods/update',
    method: 'post',
    data: {
      param: {
        goods_id: goodsId,
        ...data,
        type
      }
    }
  })
}

// 删除商品
export function deleteProduct(goodsId) {
  return request({
    url: '/goods/delete',
    method: 'post',
    data: {
      param: {
        goods_id: goodsId
      }
    }
  })
}

// 批量更新商品
export function batchUpdateProduct(data) {
  return request({
    url: '/goods/batchUpdate',
    method: 'post',
    data: {
      param: data
    }
  })
}

// 获取分类列表
export function getCategories() {
  return request({
    url: '/goods/getCategories',
    method: 'post'
  })
}

// 获取品牌列表
export function getBrands(params) {
  return request({
    url: '/goods/getBrands',
    method: 'post',
    data: {
      param: params
    }
  })
}

// 获取沐浴露类型
export function getShowerTypes() {
  return request({
    url: '/goods/getShowerTypes',
    method: 'post'
  })
}

// 商品分类相关API
// 获取分类列表
export function fetchList(params) {
  return request({
    url: '/goods/getCategories',
    method: 'post',
    data: {
      param: params
    }
  })
}

// 创建分类
export function createProductCate(data) {
  return request({
    url: '/goods/createCategory',
    method: 'post',
    data: {
      param: data
    }
  })
}

// 更新分类
export function updateProductCate(id, data) {
  return request({
    url: '/goods/updateCategory',
    method: 'post',
    data: {
      param: {
        id,
        ...data
      }
    }
  })
}

// 删除分类
export function deleteProductCate(id) {
  return request({
    url: '/goods/deleteCategory',
    method: 'post',
    data: {
      param: {
        id
      }
    }
  })
}

// 获取分类详情
export function getProductCate(id) {
  return request({
    url: '/goods/getCategory',
    method: 'post',
    data: {
      param: {
        id
      }
    }
  })
}

// 更新显示状态
export function updateShowStatus(data) {
  return request({
    url: '/goods/updateCategoryShowStatus',
    method: 'post',
    data: {
      param: data
    }
  })
}

// 更新导航状态
export function updateNavStatus(data) {
  return request({
    url: '/goods/updateCategoryNavStatus',
    method: 'post',
    data: {
      param: data
    }
  })
}

// 获取带子分类的分类列表
export function fetchListWithChildren() {
  return request({
    url: '/goods/getCategoriesWithChildren',
    method: 'post'
  })
}


export function createBrand(data) {
  return request({
    url:'/goods/createBrand',
    method:'post',
    data: {
      param: data
    }
  })
}

export function updateBrandShowStatus(data) {
  return request({
    url:'/goods/updateBrandShowStatus',
    method:'post',
    data: {
      param: data
    }
  })
}

export function updateFactoryStatus(data) {
  return request({
    url:'/goods/updateBrandFactoryStatus',
    method:'post',
    data: {
      param: data
    }
  })
}

export function deleteBrand(id) {
  return request({
    url:'/goods/deleteBrand',
    method:'post',
    data: {
      param: {
        id: id
      }
    }
  })
}

export function getBrand(id) {
  return request({
    url:'/goods/getBrand',
    method:'post',
    data: {
      param: {
        id: id
      }
    }
  })
}

export function updateBrand(id, data) {
  return request({
    url:'/goods/updateBrand',
    method:'post',
    data: {
      param: {
        id: id,
        ...data
      }
    }
  })
}